package com.tarena.lbs.content.service.impl;

import com.tarena.lbs.content.dao.repository.CategoryRepository;
import com.tarena.lbs.content.pojo.param.ArticleCategoryParam;
import com.tarena.lbs.content.pojo.po.ArticleCategoryPO;
import com.tarena.lbs.content.pojo.query.ArticleCategoryQuery;
import com.tarena.lbs.content.pojo.vo.ArticleCategoryVO;
import com.tarena.lbs.content.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Slf4j
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryRepository categoryRepository;
    @Override
    public List<ArticleCategoryVO> selectCategory(ArticleCategoryQuery categoryQuery) {
        List<ArticleCategoryVO> list=categoryRepository.selectCategory(categoryQuery);
        return list;
    }

    @Override
    public void addCategory(ArticleCategoryParam param) {
        log.info("新增分类{}",param);
        ArticleCategoryPO po=new ArticleCategoryPO();
        BeanUtils.copyProperties(param,po);
        po.setCreateTime(new Date());
        po.setUpdateTime(new Date());
        categoryRepository.insert(po);
    }
}
